WEBVTT

00:01.110 --> 00:06.550
Hello and welcome back to our assessing about Victoria's thought element y's operations service.

00:06.600 --> 00:08.120
None pay a raise.

00:08.340 --> 00:15.620
And first of all let's create an NDA Ray from scratch with the function and peer daughter range and

00:15.670 --> 00:21.500
NDP dollar range creates an array with integers and we can define that beginning and ending point.

00:21.500 --> 00:27.380
So here we want to create an NDA array from one till eleven and it's by convention.

00:27.390 --> 00:33.210
That's the beginning point the starting point us including and ending point is excluding So this is

00:33.210 --> 00:41.990
very similar to the range function which we learned before so let's create the ending array and then

00:41.990 --> 00:43.000
you can see a name.

00:43.000 --> 00:47.270
P is not defined so first of all we have to import the manpower package.

00:47.270 --> 00:54.390
So by default the number of package is not imported and before I accept that we typically we import

00:54.390 --> 01:00.960
non pi S and P but yeah we do not have to make these abbreviations so we can also just say we want to

01:00.960 --> 01:08.550
import an umpire and still not works because we didn't define M Ps but what we can do we can just write

01:08.550 --> 01:09.260
out an umpire.

01:09.260 --> 01:16.500
So the function is an umpire daughter range and then it works.

01:16.500 --> 01:21.770
However the convention is to have an abbreviation so writing out always num PIs.

01:21.850 --> 01:24.770
But a bit too much work for most of us.

01:24.840 --> 01:32.220
So it makes definitely sense to have an abbreviation so important umpire as MP and then instead of having

01:32.220 --> 01:35.790
to write out num pay every time we can just write and P

01:38.840 --> 01:44.660
and they can see we have an umpire Ray from 1 until 10 including and what we can also do we can create

01:44.660 --> 01:52.730
an umpire Ray from one till eleven excluding all ten including and only every second number is created.

01:52.760 --> 01:55.150
So let's see how it works.

01:55.210 --> 02:00.110
They can see it starting from 1 We get only every second number to 10.

02:00.280 --> 02:05.360
So 1 3 5 7 9 so eleven is already excluded.

02:05.360 --> 02:10.850
All right so in this lesson I want to highlight the difference between lists and umpire race when it

02:10.850 --> 02:18.410
comes to element y's operations on first of all let's create a list L with four elements 1 2 3 and 4.

02:18.830 --> 02:27.560
And our intention is to to multiply each element by two and if try to not just calculate l times to

02:30.210 --> 02:33.410
and we do not get them the result we we actually intended.

02:33.430 --> 02:39.740
You only get two copies of concatenated and if you want to make element y's operations we have to use

02:39.740 --> 02:47.630
a for loop so we create an empty list and for element and l we have to multiply the element and appended

02:47.630 --> 02:56.710
to the new list L1 and then we can print out the one with the multiplied elements 2 4 6 and 8 and we

02:56.710 --> 02:59.790
also know that we cannot make an element y's addition.

02:59.800 --> 03:08.140
So if we want to add two to each element in the list and to then Python drops us an error message.

03:08.770 --> 03:17.080
All right so let's create an umpire Ray from 1 to 4 is 4 elements with the function NPI range 1 2 5

03:17.080 --> 03:24.940
5 excluding we get an array with the 1 2 3 FA and now if we want to make an element y's operation so

03:24.940 --> 03:31.620
we want to multiply each element by 2 we can do this simply by saying okay our ray times 2 and this

03:31.630 --> 03:39.580
gives us element y's operation so one must multiply by 2 2 was multiplied by 2 Three was multiplied

03:39.580 --> 03:46.180
by 2 and 4 was multiplied by 2 and they are we we didn't use any for loop or something it's just them

03:46.210 --> 03:54.130
so-called vector rise the scalar operation here and also we can add each element with two that's no

03:54.130 --> 03:59.110
problem and we can also square each element to the power of two.

04:00.310 --> 04:10.160
So 1 2 the power of 2 gives us 1 to 2 the power of 2 gives us 4 3 2 the power of 2 gives us 9 and 4

04:10.170 --> 04:17.900
2 the power to give the sixteen and our vector a an umpire Ray can also serve as an exponent so two

04:17.930 --> 04:27.470
to the power of a gives us a vector of four elements so two to the power one is two to the two the power

04:27.470 --> 04:35.150
of two gets for two to the power of three gas eight and two to the power of four gives us sixteen and

04:35.150 --> 04:43.400
we can also take the square root of each element of a and also we can make an exponential motion with

04:43.400 --> 04:47.020
the E so e to the power of a

04:50.570 --> 04:56.000
and we can also calculate the natural logarithm of all elements of a.

04:57.950 --> 05:03.910
Moreover we can also take the sum of all elements so one plus two plus three plus four.

05:03.920 --> 05:06.410
There are some in the array method that some

05:09.520 --> 05:11.450
now that actually three alternatives.

05:11.450 --> 05:19.910
To sum up all elements of our array so we can use the n the Array method that some we can use the name

05:19.910 --> 05:29.170
pi function and Pitot some and then in the brackets a and also we can use just the the sum function.

05:29.180 --> 05:30.690
So some A.

05:31.520 --> 05:38.640
This also works with lists gets also 10 and we can also calculate the number of elements and then ended

05:38.640 --> 05:48.620
array by applying the attribute size so a dot size gives us far and that's actually the same functionality

05:48.660 --> 05:51.170
than the length function which we already know.

05:52.100 --> 05:59.960
And let's create a new an umpire ray with the elements minus two minus 1 minus 0 point 5 0 1 2 three

05:59.960 --> 06:09.170
point five and assign the variable B and that's also the function end Pitot EPS and what MPD EPS does

06:09.210 --> 06:16.640
it's actually calculate the absolute values of all elements so you can see here we have negative numbers

06:16.670 --> 06:23.240
and these negative numbers are transformed to positive numbers to say so minus two is two minus one

06:23.240 --> 06:27.560
this one minus 0 point five is oh point five and so on.

06:28.160 --> 06:34.880
All right so let's create another array see with the elements minus one point seven minus one point

06:34.880 --> 06:44.810
five minus 0 point 2 and so on and that's the function in P that C and what NPD out C told us actually

06:44.870 --> 06:48.970
it element was rounding up all elements to the next higher integer.

06:49.010 --> 06:51.180
So let's see what we get here.

06:51.290 --> 06:57.710
So the next higher integer of minus one point seven is minus one and the next higher integer of minus

06:57.710 --> 07:05.390
one point five is minus one and so on and for example here the next higher integer of 0 point 2 is one

07:06.050 --> 07:13.390
that's also the possibility to have an element by rounding down with the function and P top floor.

07:14.200 --> 07:21.920
So with Episode 4 we element elementals round down all elements to the next lower integer minus one

07:21.920 --> 07:32.890
point seven gives minus two minus 0 point to guess minus 1 0 point to gives zero one point seven for

07:32.890 --> 07:40.520
example I one and we can also round all elements with a given number of decimals.

07:40.560 --> 07:48.940
So let's assume here we have an list with the minus three point two three minus open seven six.

07:48.960 --> 07:52.380
And now we can define how many decimals we want to have.

07:52.380 --> 07:57.440
And here we can define 1 so we can see here.

07:57.450 --> 08:05.180
Now we rounded minus three point two three two minus three point two one point four four to one point

08:05.180 --> 08:09.390
four and two point six five to two point six then we can.

08:09.390 --> 08:18.660
Now we can also increase the number of decimals to to and I can also say I don't want to have any decimals.

08:18.860 --> 08:19.720
Now you can see here.

08:19.750 --> 08:26.900
So we have minus three minus one 1 and 3 so NPR US has actually the same functionality as the round

08:26.900 --> 08:28.850
function as we already know.

08:28.850 --> 08:29.200
All right.

08:29.200 --> 08:34.640
So this is to for the time being in this session we learn back to rise or element y's operations with

08:34.640 --> 08:35.540
an umpire race.

08:35.540 --> 08:41.770
And this is quite easy and we don't need any for loops like with the pace and standard library.

08:41.780 --> 08:48.230
And the next lesson we learn about indexing and slicing num pi raise so hope to see you there and your

08:48.230 --> 08:48.900
next session.

08:48.900 --> 08:49.130
By.
